import React from "react";
import { Button } from "@bill_law6/formily-shadcn/components/Button";
import { Input as ShadcnInput } from "@bill_law6/formily-shadcn/components/Input";
import { Checkbox as ShadcnCheckbox } from "@bill_law6/formily-shadcn/components/Checkbox";
import { Switch as ShadcnSwitch } from "@bill_law6/formily-shadcn/components/Switch";

export {
  Form,
  Field as FormItem,
  Input,
  Button as Submit,
  Checkbox,
  Switch,
} from "@bill_law6/formily-shadcn/components";

// Fallback components for missing shadcn components
export const DatePicker = ShadcnInput;
export const Cascader = ShadcnInput;
export const Editable = ShadcnInput;
export const NumberPicker = ShadcnInput;
export const Password = ShadcnInput;
export const PreviewText = ({ value, ...props }: any) => <span {...props}>{value}</span>;
export const Radio = ShadcnCheckbox;
export const Reset = Button;
export const Select = ShadcnInput;
export const Space = ({ children, ...props }: any) => <div {...props}>{children}</div>;
export const TimePicker = ShadcnInput;
export const Transfer = ShadcnInput;
export const TreeSelect = ShadcnInput;
export const Upload = ShadcnInput;
export const FormGrid = ({ children, ...props }: any) => <div {...props}>{children}</div>;
export const FormLayout = ({ children, ...props }: any) => <div {...props}>{children}</div>;
export const FormTab = ({ children, ...props }: any) => <div {...props}>{children}</div>;
export const FormCollapse = ({ children, ...props }: any) => <div {...props}>{children}</div>;
export const ArrayTable = ({ children, ...props }: any) => <div {...props}>{children}</div>;
export const ArrayCards = ({ children, ...props }: any) => <div {...props}>{children}</div>;
export const Card = ({ children, ...props }: any) => <div {...props}>{children}</div>;
export const Slider = ShadcnInput;
export const Rate = ShadcnInput;

export const Text: React.FC<{
  value?: string;
  content?: string;
  mode?: "normal" | "h1" | "h2" | "h3" | "p";
}> = ({ value, mode, content, ...props }) => {
  const tagName = mode === "normal" || !mode ? "div" : mode;
  return React.createElement(tagName, props, value || content);
};
